package com.rongcheng.applibs.net;

import java.util.concurrent.TimeUnit;

import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * Created by frc on 16-11-1.
 */

public class Generator {
    public static final int CONNECT_OUT_TIME = 10;
    public static OkHttpClient client = new OkHttpClient.Builder().connectTimeout(CONNECT_OUT_TIME, TimeUnit.SECONDS).
            writeTimeout(CONNECT_OUT_TIME,TimeUnit.SECONDS).readTimeout(CONNECT_OUT_TIME, TimeUnit.SECONDS).build();


    private static final String BASE_URL = "";
    private static Retrofit retrofit = new Retrofit.Builder().baseUrl(BASE_URL).addConverterFactory(GsonConverterFactory.create()).client(client).build();

    public static void ChangeURL(String url){
        retrofit = new Retrofit.Builder().baseUrl(url).addConverterFactory(GsonConverterFactory.create()).client(client).build();
    }

    public static <S> S createService(Class<S> serviceClass){
        return retrofit.create(serviceClass);
    }

}
